package main_app

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/theme"
	"github.com/MzoroHaHa/dev-tools/backend/app/resources"
	"image/color"
)

type DtTheme struct {
	monospace, boldItalic, bold, italic, regular fyne.Resource
}

var defaultDtTheme fyne.Theme = &DtTheme{
	monospace:  &fyne.StaticResource{StaticName: "monospace", StaticContent: resources.FontRegular},
	boldItalic: &fyne.StaticResource{StaticName: "monospace", StaticContent: resources.FontBoldItalic},
	bold:       &fyne.StaticResource{StaticName: "monospace", StaticContent: resources.FontBold},
	italic:     &fyne.StaticResource{StaticName: "monospace", StaticContent: resources.FontItalic},
	regular:    &fyne.StaticResource{StaticName: "monospace", StaticContent: resources.FontRegular},
}

func (m *DtTheme) Color(name fyne.ThemeColorName, variant fyne.ThemeVariant) color.Color {
	if name == theme.ColorNameBackground {
		return color.White
	}

	return theme.DefaultTheme().Color(name, variant)
}

func (m *DtTheme) Font(style fyne.TextStyle) fyne.Resource {
	if style.Monospace {
		return m.monospace
	}
	if style.Bold {
		if style.Italic {
			return m.boldItalic
		}
		return m.bold
	}
	if style.Italic {
		return m.italic
	}

	return m.regular
}

func (m *DtTheme) Icon(name fyne.ThemeIconName) fyne.Resource {
	return theme.DefaultTheme().Icon(name)
}

func (m *DtTheme) Size(name fyne.ThemeSizeName) float32 {
	return theme.DefaultTheme().Size(name)
}
